<?php
require_once(dirname(__FILE__) . '/../../git/handler/gitLoginHandler.php');
require_once(dirname(__FILE__) . '/../../git/util/gitConfig.php');
require_once(dirname(__FILE__) . '/../../git/util/gitApiClient.php');
require_once(dirname(__FILE__) . '/../../git/util/gitContext.php');
require_once(dirname(__FILE__) . '/OpencartAccountService.php');
require_once(dirname(__FILE__) . '/OpencartSessionManager.php');

class ContextLoader{
	public static function load($registry) {
		global $db;
		$query = $db->query("select value FROM " . DB_PREFIX ."setting where `group`='google_identity_toolkit' and `key`='google_identity_toolkit_api_key'");
		$row = $query->row;
		$apiKey = $row['value'];
		
	    $config = new gitConfig();
	    $config->setApiKey($apiKey);
	    $config->setHomeUrl(HTTP_SERVER.'index.php?route=account/git_account');
	    $config->setSignupUrl(HTTP_SERVER.'index.php?route=account/git_create');
	    $config->sessionUserKey = 'customer_id';
	    $config->idpAssertionKey = 'idpAssertion';
		$config->setPluginName("oc15");
	    gitContext::setConfig($config);
	    
	    gitContext::setAccountService(new OpencartAccountService($registry));
	    gitContext::setSessionManager(new OpencartSessionManager($registry));
	}
}
?>
